package producer.config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @ClassName AppConfig
 * @Description
 * @Author Jingxiao.Ye
 * @Date 2022/1/11 上午12:37
 * @Version V1.0
 * @Since JDK 11
 */
public class AppConfig {

    public static String name;

    public static String version;

    public static String group;

    public static int port;

    static {
        readConfig();
    }

    private static void readConfig(){
        Properties properties = new Properties();
        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("app.properties")) {
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        name = properties.getProperty("app.name");
        version = properties.getProperty("app.version");
        group = properties.getProperty("app.group");
        port = Integer.parseInt(properties.getProperty("port"));
    }
}
